﻿/**
 * This is a part of MCServe, which is available under the Apache license 2.0.
 * With this code, you may do whatever you want as long as that is not in conflict with this license.
 * In addition, you should have a reference to the original project to include (http://mcserve.codeplex.com).
 * 
 * Author       : Lars Krämer ( Xe77a )
 * Website      : http://www.lkraemer.de
 * Project      : MCServe (http://mcserve.codeplex.com)
 * Copyright    : Copyright (c) 2013 lkraemer.de
 * License      : http://mcserve.codeplex.com/license
 * Description  : This part contains general features of the project
 */

using System;

namespace MCServeLib
{
    public class MCVersion
    {
        /**
         * Enthält Versionsdaten
         */
        private Int32 _Major = 0;
        private Int32 _Minor = 0;
        private Int32 _Update = 0;

        public MCVersion()
        {
            Major = 0;
            Minor = 0;
            Update = 0;
        }
        public MCVersion(Int32 major, Int32 minor, Int32 update)
        {
            Major = major;
            Minor = minor;
            Update = update;
        }

        public Int32 Major
        {
            get
            {
                return _Major;
            }
            set
            {
                _Major = value;
            }
        }
        public Int32 Minor
        {
            get
            {
                return _Minor;
            }
            set
            {
                _Minor = value;
            }
        }
        public Int32 Update
        {
            get
            {
                return _Update;
            }
            set
            {
                _Update = value;
            }
        }

        public override string ToString()
        {
            return "v" + Major.ToString() + "." + Minor.ToString() + "." + Update.ToString() + "";
        }

        /*
        public string ToJsonString()
        {
            return "v" + Major.ToString() + "." + Minor.ToString() + "." + Update.ToString() + "";
        }
        /* */

        public static bool IsInRange(MCVersion BaseVersion, MCVersion CheckVersion)
        {
            if (CheckVersion.Major < BaseVersion.Major)
                return false;
            else if ((CheckVersion.Major >= BaseVersion.Major) && (CheckVersion.Minor < BaseVersion.Minor))
                return false;
            else if ((CheckVersion.Major >= BaseVersion.Major) && (CheckVersion.Minor >= BaseVersion.Minor) && (CheckVersion.Update < BaseVersion.Update))
                return false;
            else
                return true;
        }
    }
}